const ins = getApp()

Page({
  data: {
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    rank: {
      seeker: '--',
      employer: '--'
    }
  },
  onShow: function () {
    this.fetchRank()
  },
  CopyLink(e) {
    wx.setClipboardData({
      data: e.currentTarget.dataset.link,
      success: res => {
        wx.showToast({title: '已复制', duration: 1000})
      }
    })
  },
  fetchRank() {
    ins.api.requestApi('rank/detail/0', 'GET', {}, {
      success: (resp) => {
        if(resp.data.ret == ins.globalData.request_ret.SUCCESS) {
          const data = resp.data.data
          for(let i = 0; i < data.length; i++) {
            let item = data[i],
                field = 'rank.' + item.role.toLowerCase()
            this.setData({[field]: item.score})
          }
        }
      }
    })
  }
})
